Object.defineProperty(exports, "__esModule", { value: !0 }),
  (exports.default = void 0),
  (exports.getLocEngine = l),
  (exports.getPlugin = s),
  (exports.globalConfig = void 0);
var e,
  o = require("../../@babel/runtime/helpers/classCallCheck"),
  t = require("../../@babel/runtime/helpers/createClass"),
  n = require("../../@babel/runtime/helpers/possibleConstructorReturn"),
  a = require("../../@babel/runtime/helpers/getPrototypeOf"),
  i = require("../../@babel/runtime/helpers/inherits"),
  r =
    (e = require("./BaseLocationProvider.js")) && e.__esModule
      ? e
      : { default: e };
var c = (exports.globalConfig = {
  projectCode: "sxdgswhyz",
  apiHost: "https://location.seeklane.com",
  aoaBroker: "wxs://aoah5:seeklane2aoah52023@aoamq.sxd.cn/mqtt",
  key: "aHV2c3c/NTZ0eG1sgHZ9fT6Ed3h/gXeFfUd9iomQloOHlJmLnZ8=",
});
function s() {
  return requirePlugin("wx7ec2cc2d99561cd6");
}
function l() {}
exports.default = (function (e) {
  function r() {
    var e, t, i, c;
    return (
      o(this, r),
      (t = this),
      (i = a((i = r))),
      ((e = n(
        t,
        (function () {
          if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
          if (Reflect.construct.sham) return !1;
          if ("function" == typeof Proxy) return !0;
          try {
            return !Boolean.prototype.valueOf.call(
              Reflect.construct(Boolean, [], function () {}),
            );
          } catch (e) {
            return !1;
          }
        })()
          ? Reflect.construct(i, c || [], a(t).constructor)
          : i.apply(t, c),
      )).provideType = "aoa"),
      (e.buildingId = "5106001678889"),
      (e.locationChangeCallback = []),
      (e.loadReady = !1),
      e
    );
  }
  return (
    i(r, e),
    t(r, [
      {
        key: "init",
        value: function () {
          var e = this,
            o = arguments.length > 0 && void 0 !== arguments[0] && arguments[0],
            t = s();
          t.setEnv(wx), t.setEngine(void 0), t.setKey(c.key);
          var n = t.createLocation({
            aoaBroker: c.aoaBroker,
            useSingletonLoader: !0,
            projectCode: c.projectCode,
            apiHost: c.apiHost,
          });
          n.on("ready", function (o) {
            console.log("ready,", o),
              (e.loadReady = !0),
              console.log("数据加载成功");
          }),
            n.on("error", function (e) {
              console.error(e);
            }),
            n.on("positionChanged", function (o) {
              var t = o.value;
              e.locationChangeCallback.forEach(function (o) {
                var n = "F1";
                -3 === t.z && (n = "B1"), 3 === t.z && (n = "F2");
                var a = {
                  latitude: t.y,
                  longitude: t.x,
                  buildingId: e.buildingId,
                  floorName: n,
                  accuracy: 10,
                };
                o && o(a);
              }),
                console.log("====positionChanged", t);
            }),
            n.on("headingChanged", function (e) {}),
            n.loadMap(),
            (this.locationApp = n),
            o &&
              (this.locationApp.sensorManager.aoaLocator._sysMac =
                "3CFAD3B00001");
        },
      },
      {
        key: "startLocation",
        value: function () {
          var e = this,
            o =
              arguments.length > 0 && void 0 !== arguments[0]
                ? arguments[0]
                : {},
            t = o.success,
            n = o.fail;
          if (this.loadReady) {
            var a = this;
            wx.getSetting({
              success: function (e) {
                e.authSetting["scope.userLocation"]
                  ? (t && t(),
                    a.locationApp && a.locationApp.startLocationService())
                  : wx.authorize({
                      scope: "scope.userLocation",
                      success: function (e) {
                        a.locationApp.startLocationService(), t && t();
                      },
                      fail: function (e) {
                        console.warn("wx.authorize userLocation fail!!!!"),
                          n && n();
                      },
                    });
              },
              fail: function (e) {
                n && n();
              },
            });
          } else
            setTimeout(function () {
              e.startLocation(o);
            }, 1e3);
        },
      },
      {
        key: "onLocationChange",
        value: function (e) {
          this.locationChangeCallback.push(e);
        },
      },
      {
        key: "stopLocation",
        value: function () {
          this.locationApp && this.locationApp.stopLocationService();
        },
      },
      {
        key: "dispose",
        value: function () {
          (this.locationChangeCallback = []), this.locationApp.destr;
        },
      },
    ])
  );
})(r.default);
